home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_06 / saks / strq1.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-08  |  688 b   |  48 lines

  1. Listing 3 - class definitions for a queue of str using a non-nested cell 
  2. type
  3.  
  4. //
  5. // strq1.h - a queue of str (interface)
  6. //
  7.  
  8. #include <iostream.h>
  9.  
  10. #include "str.h"
  11.  
  12. class strq_cell
  13.     {
  14.     friend class strq;
  15. private:
  16.     strq_cell(const str &e, strq_cell *p);
  17.     strq_cell *next;
  18.     str element;
  19.     };
  20.  
  21. class strq
  22.     {
  23. public:
  24.     strq();
  25.     ~strq();
  26.     void append(const str &e);
  27.     void clear();
  28.     void print(ostream &os) const;
  29.     int remove(str &e);
  30. private:
  31.     strq_cell *first, *last;
  32.     };
  33.  
  34. inline strq_cell::strq_cell(const str &e, strq_cell *p)
  35.     : element(e), next(p)
  36.     {
  37.     }
  38.  
  39. inline strq::strq() : first(0), last(0)
  40.     {
  41.     }
  42.  
  43. inline strq::~strq()
  44.     {
  45.     clear();
  46.     }
  47.  
  48.